<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\api\controller\learn;

use app\api\controller\Controller;
use app\api\model\learn\Chat as ChatModel;
use think\facade\Db;
use think\response\Json;

/**
 * 黑名单管理
 * Class Chat
 * @package app\api\controller\order
 */
class Chat extends Controller {
	/**
	 * 列表
	 * @param int $orderId
	 * @return Json
	 * @throws \cores\exception\BaseException
	 * @throws \think\db\exception\DataNotFoundException
	 * @throws \think\db\exception\DbException
	 * @throws \think\db\exception\ModelNotFoundException
	 */
	public function list(): Json {

		$model = new ChatModel;
		$list = $model->getList($this->request->param());

		return $this->renderSuccess(compact('list'));
	}
	public function getChat(int $followId): Json {

		$model = new ChatModel;

		$chat=$model->getChat($followId);

		return $this->renderSuccess(compact('chat'));
	}
	public function del(int $logId): Json {

		Db::name('learn_Chat')->where('log_id', $logId)->delete();

		return $this->renderSuccess();
	}
	/**
	 *
	 * @param int $orderId
	 * @return Json
	 * @throws \cores\exception\BaseException
	 * @throws \think\db\exception\DataNotFoundException
	 * @throws \think\db\exception\DbException
	 * @throws \think\db\exception\ModelNotFoundException
	 */
	public function submit(): Json {

		// 提交商品评价
		$model = new ChatModel;
		if ($model->increased($this->postForm())) {
			return $this->renderSuccess([], '发表成功');
		}
		return $this->renderError($model->getError() ?: '发表失败');
	}
	public function collectSave(): Json {

		// 提交商品评价
		$model = new ChatModel;
		if ($model->collectSave($this->postForm())) {
			return $this->renderSuccess([], '发表成功');
		}
		return $this->renderError($model->getError() ?: '发表失败');
	}
}